# !pip install git+https://github.com/alberanid/imdbpy
# !pip install pandas
# !pip install numpy
# !pip install matplotlib
# !pip install seaborn
# !pip install pandas_profiling --upgrade
# !pip install plotly
# !pip install wordcloud
# !pip install Flask
# Import Dataset
# Import File from Loacal Drive
# from google.colab import files
# data_to_load = files.upload()
# from google.colab import drive
# drive.mount('/content/drive')
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import warnings
import collections
import plotly.express as px
import plotly.graph_objects as go
import nltk
import re
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
from nltk.probability import FreqDist
from nltk.util import ngrams
from plotly.subplots import make_subplots
from plotly.offline import iplot, init_notebook_mode
from wordcloud import WordCloud, STOPWORDS
from pandas_profiling import ProfileReport
%matplotlib inline
warnings.filterwarnings("ignore")
nltk.download('all')
[nltk_data] Downloading collection 'all' [nltk_data] | [nltk_data] | Downloading package abc to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package abc is already up-to-date! [nltk_data] | Downloading package alpino to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package alpino is already up-to-date! [nltk_data] | Downloading package biocreative_ppi to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package biocreative_ppi is already up-to-date! [nltk_data] | Downloading package brown to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package brown is already up-to-date! [nltk_data] | Downloading package brown_tei to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package brown_tei is already up-to-date! [nltk_data] | Downloading package cess_cat to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package cess_cat is already up-to-date! [nltk_data] | Downloading package cess_esp to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package cess_esp is already up-to-date! [nltk_data] | Downloading package chat80 to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package chat80 is already up-to-date! [nltk_data] | Downloading package city_database to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package city_database is already up-to-date! [nltk_data] | Downloading package cmudict to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package cmudict is already up-to-date! [nltk_data] | Downloading package comparative_sentences to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package comparative_sentences is already up-to- [nltk_data] | date! [nltk_data] | Downloading package comtrans to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package comtrans is already up-to-date! [nltk_data] | Downloading package conll2000 to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package conll2000 is already up-to-date! [nltk_data] | Downloading package conll2002 to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package conll2002 is already up-to-date! [nltk_data] | Downloading package conll2007 to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package conll2007 is already up-to-date! [nltk_data] | Downloading package crubadan to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package crubadan is already up-to-date! [nltk_data] | Downloading package dependency_treebank to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package dependency_treebank is already up-to-date! [nltk_data] | Downloading package dolch to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package dolch is already up-to-date! [nltk_data] | Downloading package europarl_raw to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package europarl_raw is already up-to-date! [nltk_data] | Downloading package floresta to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package floresta is already up-to-date! [nltk_data] | Downloading package framenet_v15 to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package framenet_v15 is already up-to-date! [nltk_data] | Downloading package framenet_v17 to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package framenet_v17 is already up-to-date! [nltk_data] | Downloading package gazetteers to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package gazetteers is already up-to-date! [nltk_data] | Downloading package genesis to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package genesis is already up-to-date! [nltk_data] | Downloading package gutenberg to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package gutenberg is already up-to-date! [nltk_data] | Downloading package ieer to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package ieer is already up-to-date! [nltk_data] | Downloading package inaugural to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package inaugural is already up-to-date! [nltk_data] | Downloading package indian to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package indian is already up-to-date! [nltk_data] | Downloading package jeita to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package jeita is already up-to-date! [nltk_data] | Downloading package kimmo to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package kimmo is already up-to-date! [nltk_data] | Downloading package knbc to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package knbc is already up-to-date! [nltk_data] | Downloading package lin_thesaurus to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package lin_thesaurus is already up-to-date! [nltk_data] | Downloading package mac_morpho to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package mac_morpho is already up-to-date! [nltk_data] | Downloading package machado to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package machado is already up-to-date! [nltk_data] | Downloading package masc_tagged to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package masc_tagged is already up-to-date! [nltk_data] | Downloading package moses_sample to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package moses_sample is already up-to-date! [nltk_data] | Downloading package movie_reviews to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package movie_reviews is already up-to-date! [nltk_data] | Downloading package names to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package names is already up-to-date! [nltk_data] | Downloading package nombank.1.0 to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package nombank.1.0 is already up-to-date! [nltk_data] | Downloading package nps_chat to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package nps_chat is already up-to-date! [nltk_data] | Downloading package omw to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package omw is already up-to-date! [nltk_data] | Downloading package opinion_lexicon to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package opinion_lexicon is already up-to-date! [nltk_data] | Downloading package paradigms to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package paradigms is already up-to-date! [nltk_data] | Downloading package pil to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package pil is already up-to-date! [nltk_data] | Downloading package pl196x to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package pl196x is already up-to-date! [nltk_data] | Downloading package ppattach to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package ppattach is already up-to-date! [nltk_data] | Downloading package problem_reports to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package problem_reports is already up-to-date! [nltk_data] | Downloading package propbank to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package propbank is already up-to-date! [nltk_data] | Downloading package ptb to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package ptb is already up-to-date! [nltk_data] | Downloading package product_reviews_1 to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package product_reviews_1 is already up-to-date! [nltk_data] | Downloading package product_reviews_2 to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package product_reviews_2 is already up-to-date! [nltk_data] | Downloading package pros_cons to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package pros_cons is already up-to-date! [nltk_data] | Downloading package qc to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package qc is already up-to-date! [nltk_data] | Downloading package reuters to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package reuters is already up-to-date! [nltk_data] | Downloading package rte to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package rte is already up-to-date! [nltk_data] | Downloading package semcor to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package semcor is already up-to-date! [nltk_data] | Downloading package senseval to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package senseval is already up-to-date! [nltk_data] | Downloading package sentiwordnet to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package sentiwordnet is already up-to-date! [nltk_data] | Downloading package sentence_polarity to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package sentence_polarity is already up-to-date! [nltk_data] | Downloading package shakespeare to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package shakespeare is already up-to-date! [nltk_data] | Downloading package sinica_treebank to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package sinica_treebank is already up-to-date! [nltk_data] | Downloading package smultron to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package smultron is already up-to-date! [nltk_data] | Downloading package state_union to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package state_union is already up-to-date! [nltk_data] | Downloading package stopwords to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package stopwords is already up-to-date! [nltk_data] | Downloading package subjectivity to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package subjectivity is already up-to-date! [nltk_data] | Downloading package swadesh to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package swadesh is already up-to-date! [nltk_data] | Downloading package switchboard to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package switchboard is already up-to-date! [nltk_data] | Downloading package timit to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package timit is already up-to-date! [nltk_data] | Downloading package toolbox to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package toolbox is already up-to-date! [nltk_data] | Downloading package treebank to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package treebank is already up-to-date! [nltk_data] | Downloading package twitter_samples to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package twitter_samples is already up-to-date! [nltk_data] | Downloading package udhr to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package udhr is already up-to-date! [nltk_data] | Downloading package udhr2 to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package udhr2 is already up-to-date! [nltk_data] | Downloading package unicode_samples to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package unicode_samples is already up-to-date! [nltk_data] | Downloading package universal_treebanks_v20 to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package universal_treebanks_v20 is already up-to- [nltk_data] | date! [nltk_data] | Downloading package verbnet to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package verbnet is already up-to-date! [nltk_data] | Downloading package verbnet3 to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package verbnet3 is already up-to-date! [nltk_data] | Downloading package webtext to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package webtext is already up-to-date! [nltk_data] | Downloading package wordnet to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package wordnet is already up-to-date! [nltk_data] | Downloading package wordnet_ic to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package wordnet_ic is already up-to-date! [nltk_data] | Downloading package words to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package words is already up-to-date! [nltk_data] | Downloading package ycoe to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package ycoe is already up-to-date! [nltk_data] | Downloading package rslp to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package rslp is already up-to-date! [nltk_data] | Downloading package maxent_treebank_pos_tagger to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package maxent_treebank_pos_tagger is already up- [nltk_data] | to-date! [nltk_data] | Downloading package universal_tagset to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package universal_tagset is already up-to-date! [nltk_data] | Downloading package maxent_ne_chunker to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package maxent_ne_chunker is already up-to-date! [nltk_data] | Downloading package punkt to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package punkt is already up-to-date! [nltk_data] | Downloading package book_grammars to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package book_grammars is already up-to-date! [nltk_data] | Downloading package sample_grammars to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package sample_grammars is already up-to-date! [nltk_data] | Downloading package spanish_grammars to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package spanish_grammars is already up-to-date! [nltk_data] | Downloading package basque_grammars to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package basque_grammars is already up-to-date! [nltk_data] | Downloading package large_grammars to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package large_grammars is already up-to-date! [nltk_data] | Downloading package tagsets to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package tagsets is already up-to-date! [nltk_data] | Downloading package snowball_data to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package snowball_data is already up-to-date! [nltk_data] | Downloading package bllip_wsj_no_aux to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package bllip_wsj_no_aux is already up-to-date! [nltk_data] | Downloading package word2vec_sample to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package word2vec_sample is already up-to-date! [nltk_data] | Downloading package panlex_swadesh to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package panlex_swadesh is already up-to-date! [nltk_data] | Downloading package mte_teip5 to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package mte_teip5 is already up-to-date! [nltk_data] | Downloading package averaged_perceptron_tagger to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package averaged_perceptron_tagger is already up- [nltk_data] | to-date! [nltk_data] | Downloading package averaged_perceptron_tagger_ru to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package averaged_perceptron_tagger_ru is already [nltk_data] | up-to-date! [nltk_data] | Downloading package perluniprops to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package perluniprops is already up-to-date! [nltk_data] | Downloading package nonbreaking_prefixes to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package nonbreaking_prefixes is already up-to-date! [nltk_data] | Downloading package vader_lexicon to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package vader_lexicon is already up-to-date! [nltk_data] | Downloading package porter_test to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package porter_test is already up-to-date! [nltk_data] | Downloading package wmt15_eval to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package wmt15_eval is already up-to-date! [nltk_data] | Downloading package mwa_ppdb to [nltk_data] | C:\Users\pawan\AppData\Roaming\nltk_data... [nltk_data] | Package mwa_ppdb is already up-to-date! [nltk_data] | [nltk_data] Done downloading collection all
True
# path = '/content/drive/MyDrive/Files/'
path = 'C:\\Users\\pawan\\OneDrive\\Desktop\\ott\\Data\\'
df_movies = pd.read_csv(path + 'ottmovies.csv')
df_movies.head()
| ID | Title | Year | Age | IMDb | Rotten Tomatoes | Directors | Cast | Genres | Country | Language | Plotline | Runtime | Kind | Seasons | Netflix | Hulu | Prime Video | Disney+ | Type | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | Inception | 2010 | 13+ | 8.8 | 87% | Christopher Nolan | Leonardo DiCaprio,Joseph Gordon-Levitt,Elliot ... | Action,Adventure,Sci-Fi,Thriller | United States,United Kingdom | English,Japanese,French | Dom Cobb is a skilled thief, the absolute best... | 148.0 | movie | NaN | 1 | 0 | 0 | 0 | 0 |
| 1 | 2 | The Matrix | 1999 | 16+ | 8.7 | 88% | Lana Wachowski,Lilly Wachowski | Keanu Reeves,Laurence Fishburne,Carrie-Anne Mo... | Action,Sci-Fi | United States | English | Thomas A. Anderson is a man living two lives. ... | 136.0 | movie | NaN | 1 | 0 | 0 | 0 | 0 |
| 2 | 3 | Avengers: Infinity War | 2018 | 13+ | 8.4 | 85% | Anthony Russo,Joe Russo | Robert Downey Jr.,Chris Hemsworth,Mark Ruffalo... | Action,Adventure,Sci-Fi | United States | English | As the Avengers and their allies have continue... | 149.0 | movie | NaN | 1 | 0 | 0 | 0 | 0 |
| 3 | 4 | Back to the Future | 1985 | 7+ | 8.5 | 96% | Robert Zemeckis | Michael J. Fox,Christopher Lloyd,Lea Thompson,... | Adventure,Comedy,Sci-Fi | United States | English | Marty McFly, a typical American teenager of th... | 116.0 | movie | NaN | 1 | 0 | 0 | 0 | 0 |
| 4 | 5 | The Good, the Bad and the Ugly | 1966 | 16+ | 8.8 | 97% | Sergio Leone | Eli Wallach,Clint Eastwood,Lee Van Cleef,Aldo ... | Western | Italy,Spain,West Germany,United States | Italian | Blondie (The Good) (Clint Eastwood) is a profe... | 161.0 | movie | NaN | 1 | 0 | 1 | 0 | 0 |
# profile = ProfileReport(df_movies)
# profile
def data_investigate(df):
print('No of Rows : ', df.shape[0])
print('No of Coloums : ', df.shape[1])
print('**'*25)
print('Colums Names : \n', df.columns)
print('**'*25)
print('Datatype of Columns : \n', df.dtypes)
print('**'*25)
print('Missing Values : ')
c = df.isnull().sum()
c = c[c > 0]
print(c)
print('**'*25)
print('Missing vaules %age wise :\n')
print((100*(df.isnull().sum()/len(df.index))))
print('**'*25)
print('Pictorial Representation : ')
plt.figure(figsize = (10, 10))
sns.heatmap(df.isnull(), yticklabels = False, cbar = False)
plt.show()
data_investigate(df_movies)
No of Rows : 16923
No of Coloums : 20
**************************************************
Colums Names :
Index(['ID', 'Title', 'Year', 'Age', 'IMDb', 'Rotten Tomatoes', 'Directors',
'Cast', 'Genres', 'Country', 'Language', 'Plotline', 'Runtime', 'Kind',
'Seasons', 'Netflix', 'Hulu', 'Prime Video', 'Disney+', 'Type'],
dtype='object')
**************************************************
Datatype of Columns :
ID int64
Title object
Year int64
Age object
IMDb float64
Rotten Tomatoes object
Directors object
Cast object
Genres object
Country object
Language object
Plotline object
Runtime float64
Kind object
Seasons float64
Netflix int64
Hulu int64
Prime Video int64
Disney+ int64
Type int64
dtype: object
**************************************************
Missing Values :
Age 8457
IMDb 328
Rotten Tomatoes 10437
Directors 357
Cast 648
Genres 234
Country 303
Language 437
Plotline 4958
Runtime 382
Seasons 16923
dtype: int64
**************************************************
Missing vaules %age wise :
ID 0.000000
Title 0.000000
Year 0.000000
Age 49.973409
IMDb 1.938191
Rotten Tomatoes 61.673462
Directors 2.109555
Cast 3.829108
Genres 1.382734
Country 1.790463
Language 2.582284
Plotline 29.297406
Runtime 2.257283
Kind 0.000000
Seasons 100.000000
Netflix 0.000000
Hulu 0.000000
Prime Video 0.000000
Disney+ 0.000000
Type 0.000000
dtype: float64
**************************************************
Pictorial Representation :
# ID
# df_movies = df_movies.drop(['ID'], axis = 1)
# Age
df_movies.loc[df_movies['Age'].isnull() & df_movies['Disney+'] == 1, "Age"] = '13'
# df_movies.fillna({'Age' : 18}, inplace = True)
df_movies.fillna({'Age' : 'NR'}, inplace = True)
df_movies['Age'].replace({'all': '0'}, inplace = True)
df_movies['Age'].replace({'7+': '7'}, inplace = True)
df_movies['Age'].replace({'13+': '13'}, inplace = True)
df_movies['Age'].replace({'16+': '16'}, inplace = True)
df_movies['Age'].replace({'18+': '18'}, inplace = True)
# df_movies['Age'] = df_movies['Age'].astype(int)
# IMDb
# df_movies.fillna({'IMDb' : df_movies['IMDb'].mean()}, inplace = True)
# df_movies.fillna({'IMDb' : df_movies['IMDb'].median()}, inplace = True)
df_movies.fillna({'IMDb' : "NA"}, inplace = True)
# Rotten Tomatoes
df_movies['Rotten Tomatoes'] = df_movies['Rotten Tomatoes'][df_movies['Rotten Tomatoes'].notnull()].str.replace('%', '').astype(int)
# df_movies['Rotten Tomatoes'] = df_movies['Rotten Tomatoes'][df_movies['Rotten Tomatoes'].notnull()].astype(int)
# df_movies.fillna({'Rotten Tomatoes' : df_movies['Rotten Tomatoes'].mean()}, inplace = True)
# df_movies.fillna({'Rotten Tomatoes' : df_movies['Rotten Tomatoes'].median()}, inplace = True)
# df_movies['Rotten Tomatoes'] = df_movies['Rotten Tomatoes'].astype(int)
df_movies.fillna({'Rotten Tomatoes' : "NA"}, inplace = True)
# Directors
# df_movies = df_movies.drop(['Directors'], axis = 1)
df_movies.fillna({'Directors' : "NA"}, inplace = True)
# Cast
df_movies.fillna({'Cast' : "NA"}, inplace = True)
# Genres
df_movies.fillna({'Genres': "NA"}, inplace = True)
# Country
df_movies.fillna({'Country': "NA"}, inplace = True)
# Language
df_movies.fillna({'Language': "NA"}, inplace = True)
# Plotline
df_movies.fillna({'Plotline': "NA"}, inplace = True)
# Runtime
# df_movies.fillna({'Runtime' : df_movies['Runtime'].mean()}, inplace = True)
# df_movies['Runtime'] = df_movies['Runtime'].astype(int)
df_movies.fillna({'Runtime' : "NA"}, inplace = True)
# Kind
# df_movies.fillna({'Kind': "NA"}, inplace = True)
# Type
# df_movies.fillna({'Type': "NA"}, inplace = True)
# df_movies = df_movies.drop(['Type'], axis = 1)
# Seasons
# df_movies.fillna({'Seasons': 1}, inplace = True)
# df_movies.fillna({'Seasons': "NA"}, inplace = True)
df_movies = df_movies.drop(['Seasons'], axis = 1)
# df_movies['Seasons'] = df_movies['Seasons'].astype(int)
# df_movies.fillna({'Seasons' : df_movies['Seasons'].mean()}, inplace = True)
# df_movies['Seasons'] = df_movies['Seasons'].astype(int)
# Service Provider
df_movies['Service Provider'] = df_movies.loc[:, ['Netflix', 'Prime Video', 'Disney+', 'Hulu']].idxmax(axis = 1)
# df_movies.drop(['Netflix','Prime Video','Disney+','Hulu'], axis = 1)
# Removing Duplicate and Missing Entries
df_movies.dropna(how = 'any', inplace = True)
df_movies.drop_duplicates(inplace = True)
data_investigate(df_movies)
No of Rows : 16923
No of Coloums : 20
**************************************************
Colums Names :
Index(['ID', 'Title', 'Year', 'Age', 'IMDb', 'Rotten Tomatoes', 'Directors',
'Cast', 'Genres', 'Country', 'Language', 'Plotline', 'Runtime', 'Kind',
'Netflix', 'Hulu', 'Prime Video', 'Disney+', 'Type',
'Service Provider'],
dtype='object')
**************************************************
Datatype of Columns :
ID int64
Title object
Year int64
Age object
IMDb object
Rotten Tomatoes object
Directors object
Cast object
Genres object
Country object
Language object
Plotline object
Runtime object
Kind object
Netflix int64
Hulu int64
Prime Video int64
Disney+ int64
Type int64
Service Provider object
dtype: object
**************************************************
Missing Values :
Series([], dtype: int64)
**************************************************
Missing vaules %age wise :
ID 0.0
Title 0.0
Year 0.0
Age 0.0
IMDb 0.0
Rotten Tomatoes 0.0
Directors 0.0
Cast 0.0
Genres 0.0
Country 0.0
Language 0.0
Plotline 0.0
Runtime 0.0
Kind 0.0
Netflix 0.0
Hulu 0.0
Prime Video 0.0
Disney+ 0.0
Type 0.0
Service Provider 0.0
dtype: float64
**************************************************
Pictorial Representation :
df_movies.head()
| ID | Title | Year | Age | IMDb | Rotten Tomatoes | Directors | Cast | Genres | Country | Language | Plotline | Runtime | Kind | Netflix | Hulu | Prime Video | Disney+ | Type | Service Provider | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | Inception | 2010 | 13 | 8.8 | 87 | Christopher Nolan | Leonardo DiCaprio,Joseph Gordon-Levitt,Elliot ... | Action,Adventure,Sci-Fi,Thriller | United States,United Kingdom | English,Japanese,French | Dom Cobb is a skilled thief, the absolute best... | 148 | movie | 1 | 0 | 0 | 0 | 0 | Netflix |
| 1 | 2 | The Matrix | 1999 | 16 | 8.7 | 88 | Lana Wachowski,Lilly Wachowski | Keanu Reeves,Laurence Fishburne,Carrie-Anne Mo... | Action,Sci-Fi | United States | English | Thomas A. Anderson is a man living two lives. ... | 136 | movie | 1 | 0 | 0 | 0 | 0 | Netflix |
| 2 | 3 | Avengers: Infinity War | 2018 | 13 | 8.4 | 85 | Anthony Russo,Joe Russo | Robert Downey Jr.,Chris Hemsworth,Mark Ruffalo... | Action,Adventure,Sci-Fi | United States | English | As the Avengers and their allies have continue... | 149 | movie | 1 | 0 | 0 | 0 | 0 | Netflix |
| 3 | 4 | Back to the Future | 1985 | 7 | 8.5 | 96 | Robert Zemeckis | Michael J. Fox,Christopher Lloyd,Lea Thompson,... | Adventure,Comedy,Sci-Fi | United States | English | Marty McFly, a typical American teenager of th... | 116 | movie | 1 | 0 | 0 | 0 | 0 | Netflix |
| 4 | 5 | The Good, the Bad and the Ugly | 1966 | 16 | 8.8 | 97 | Sergio Leone | Eli Wallach,Clint Eastwood,Lee Van Cleef,Aldo ... | Western | Italy,Spain,West Germany,United States | Italian | Blondie (The Good) (Clint Eastwood) is a profe... | 161 | movie | 1 | 0 | 1 | 0 | 0 | Netflix |
df_movies.describe()
| ID | Year | Netflix | Hulu | Prime Video | Disney+ | Type | |
|---|---|---|---|---|---|---|---|
| count | 16923.000000 | 16923.000000 | 16923.000000 | 16923.000000 | 16923.000000 | 16923.000000 | 16923.0 |
| mean | 8462.000000 | 2003.211901 | 0.214915 | 0.062637 | 0.727235 | 0.033150 | 0.0 |
| std | 4885.393638 | 20.526532 | 0.410775 | 0.242315 | 0.445394 | 0.179034 | 0.0 |
| min | 1.000000 | 1901.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.0 |
| 25% | 4231.500000 | 2001.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.0 |
| 50% | 8462.000000 | 2012.000000 | 0.000000 | 0.000000 | 1.000000 | 0.000000 | 0.0 |
| 75% | 12692.500000 | 2016.000000 | 0.000000 | 0.000000 | 1.000000 | 0.000000 | 0.0 |
| max | 16923.000000 | 2020.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 0.0 |
df_movies.corr()
| ID | Year | Netflix | Hulu | Prime Video | Disney+ | Type | |
|---|---|---|---|---|---|---|---|
| ID | 1.000000 | -0.217816 | -0.644470 | -0.129926 | 0.469301 | 0.263530 | NaN |
| Year | -0.217816 | 1.000000 | 0.256151 | 0.101337 | -0.255578 | -0.047258 | NaN |
| Netflix | -0.644470 | 0.256151 | 1.000000 | -0.118032 | -0.745141 | -0.089649 | NaN |
| Hulu | -0.129926 | 0.101337 | -0.118032 | 1.000000 | -0.284654 | -0.039693 | NaN |
| Prime Video | 0.469301 | -0.255578 | -0.745141 | -0.284654 | 1.000000 | -0.289008 | NaN |
| Disney+ | 0.263530 | -0.047258 | -0.089649 | -0.039693 | -0.289008 | 1.000000 | NaN |
| Type | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
# df_movies.sort_values('Year', ascending = True)
# df_movies.sort_values('IMDb', ascending = False)
# df_movies.to_csv(path_or_buf= '/content/drive/MyDrive/Files/updated_ottmovies.csv', index = False)
# path = '/content/drive/MyDrive/Files/'
# udf_movies = pd.read_csv(path + 'updated_ottmovies.csv')
# udf_movies
# df_netflix_movies = df_movies.loc[(df_movies['Netflix'] > 0)]
# df_hulu_movies = df_movies.loc[(df_movies['Hulu'] > 0)]
# df_prime_video_movies = df_movies.loc[(df_movies['Prime Video'] > 0)]
# df_disney_movies = df_movies.loc[(df_movies['Disney+'] > 0)]
df_netflix_only_movies = df_movies[(df_movies['Netflix'] == 1) & (df_movies['Hulu'] == 0) & (df_movies['Prime Video'] == 0 ) & (df_movies['Disney+'] == 0)]
df_hulu_only_movies = df_movies[(df_movies['Netflix'] == 0) & (df_movies['Hulu'] == 1) & (df_movies['Prime Video'] == 0 ) & (df_movies['Disney+'] == 0)]
df_prime_video_only_movies = df_movies[(df_movies['Netflix'] == 0) & (df_movies['Hulu'] == 0) & (df_movies['Prime Video'] == 1 ) & (df_movies['Disney+'] == 0)]
df_disney_only_movies = df_movies[(df_movies['Netflix'] == 0) & (df_movies['Hulu'] == 0) & (df_movies['Prime Video'] == 0 ) & (df_movies['Disney+'] == 1)]
df_movies_plotline = df_movies.copy()
df_movies_plotline.drop(df_movies_plotline.loc[df_movies_plotline['Plotline'] == "NA"].index, inplace = True)
# df_movies_plotline = df_movies_plotline[df_movies_plotline.Plotline != "NA"]
# Creating distinct dataframes only with the movies present on individual streaming platforms
netflix_plotline_movies = df_movies_plotline.loc[df_movies_plotline['Netflix'] == 1]
hulu_plotline_movies = df_movies_plotline.loc[df_movies_plotline['Hulu'] == 1]
prime_video_plotline_movies = df_movies_plotline.loc[df_movies_plotline['Prime Video'] == 1]
disney_plotline_movies = df_movies_plotline.loc[df_movies_plotline['Disney+'] == 1]
plt.figure(figsize = (10, 10))
corr = df_movies_plotline.corr()
# Plot figsize
fig, ax = plt.subplots(figsize=(10, 8))
# Generate Heat Map, allow annotations and place floats in map
sns.heatmap(corr, cmap = 'magma', annot = True, fmt = ".2f")
# Apply xticks
plt.xticks(range(len(corr.columns)), corr.columns);
# Apply yticks
plt.yticks(range(len(corr.columns)), corr.columns)
# show plot
plt.show()
fig.show()
<Figure size 720x720 with 0 Axes>
df_movies_plotline = df_movies_plotline['Plotline']
movies_plotline_w = ' '.join(df_movies_plotline)
stopwords = set(STOPWORDS)
wordcloud_all_plotline_movies = WordCloud(width = 1000, height = 500,
background_color ='white',
stopwords = stopwords,
min_font_size = 10).generate(movies_plotline_w)
# plot the WordCloud image
plt.figure(figsize = (20, 10), facecolor = None)
plt.imshow(wordcloud_all_plotline_movies)
plt.axis("off")
plt.tight_layout(pad = 0)
plt.show()
movies_plotline_w = movies_plotline_w.lower()
stop_words_english_movies = set(STOPWORDS)
word_tokens_english_movies = word_tokenize(movies_plotline_w)
filtered_movie_plotline = [w for w in word_tokens_english_movies if not w in stop_words_english_movies]
filtered_movie_plotline = " ".join(filtered_movie_plotline)
filtered_movie_plotline = re.sub("'s", '', filtered_movie_plotline)
filtered_movie_plotline = re.sub(r'[0-9]+', '', filtered_movie_plotline)
final_movie_plotline = re.sub(r'[^\w\s]', '', filtered_movie_plotline)
plotline_movies_corpus_len = len(filtered_movie_plotline.split())
plotline_movies_corpus_len
818331
def extract_ngrams(data, num):
n_grams = ngrams(nltk.word_tokenize(data), num)
return [ ' '.join(grams) for grams in n_grams]
plotline_ngram1_movies = FreqDist()
plotline_ngram1 = extract_ngrams(final_movie_plotline[:plotline_movies_corpus_len], 1)
for word in plotline_ngram1:
plotline_ngram1_movies[word.lower()] += 1
plotline_ngram1_movies.most_common(10)
[('life', 627),
('one', 624),
('will', 577),
('family', 437),
('new', 414),
('love', 408),
('world', 402),
('story', 365),
('two', 363),
('man', 351)]
plotline_ngram2_movies = FreqDist()
plotline_ngram2 = extract_ngrams(final_movie_plotline[:plotline_movies_corpus_len], 2)
for word in plotline_ngram2:
plotline_ngram2_movies[word.lower()] += 1
plotline_ngram2_movies.most_common(10)
[('high school', 69),
('new york', 61),
('one day', 57),
('best friend', 54),
('young man', 43),
('falls love', 42),
('ca nt', 40),
('years later', 39),
('young woman', 39),
('year old', 34)]
plotline_ngram3_movies = FreqDist()
plotline_ngram3 = extract_ngrams(final_movie_plotline[:plotline_movies_corpus_len], 3)
for word in plotline_ngram3:
plotline_ngram3_movies[word.lower()] += 1
plotline_ngram3_movies.most_common(10)
[('new york city', 29),
('based true story', 11),
('story revolves around', 8),
('world war ii', 7),
('game cat mouse', 7),
('will stop nothing', 6),
('academy award nominated', 6),
('high school senior', 6),
('year high school', 6),
('make matters worse', 6)]
plotline_ngram4_movies = FreqDist()
plotline_ngram4 = extract_ngrams(final_movie_plotline[:plotline_movies_corpus_len], 4)
for word in plotline_ngram4:
plotline_ngram4_movies[word.lower()] += 1
plotline_ngram4_movies.most_common(10)
[('barcelona catalonia northeast spain', 5),
('academy award nominated filmmaker', 3),
('james bond pierce brosnan', 3),
('dame kristin scott thomas', 3),
('will change life forever', 3),
('deadly game cat mouse', 3),
('basque country north spain', 3),
('make world better place', 2),
('will whatever takes achieve', 2),
('agent james bond pierce', 2)]
plotline_ngram5_movies = FreqDist()
plotline_ngram5 = extract_ngrams(final_movie_plotline[:plotline_movies_corpus_len], 5)
for word in plotline_ngram5:
plotline_ngram5_movies[word.lower()] += 1
plotline_ngram5_movies.most_common(10)
[('agent james bond pierce brosnan', 2),
('emerging demand hyperfuel resources han', 2),
('demand hyperfuel resources han solo', 2),
('hyperfuel resources han solo finds', 2),
('resources han solo finds middle', 2),
('han solo finds middle heist', 2),
('solo finds middle heist alongside', 2),
('finds middle heist alongside criminals', 2),
('middle heist alongside criminals meet', 2),
('heist alongside criminals meet likes', 2)]
# Netflix Wordcloud
netflix_plotline_movies_t = netflix_plotline_movies['Plotline']
netflix_movies_plotline_w = ' '.join(netflix_plotline_movies_t)
stopwords = set(STOPWORDS)
wordcloud_netflix_plotline_movies = WordCloud(width = 1000, height = 500,
background_color ='white',
stopwords = stopwords,
min_font_size = 10
).generate(netflix_movies_plotline_w)
print('\nThe Wordcloud Generated from Plotlines of Netflix is : \n')
# plot the WordCloud image
plt.figure(figsize = (20, 10), facecolor = None)
plt.imshow(wordcloud_netflix_plotline_movies)
plt.axis("off")
plt.tight_layout(pad = 0)
plt.show()
The Wordcloud Generated from Plotlines of Netflix is :
# Hulu Wordcloud
hulu_plotline_movies_t = hulu_plotline_movies['Plotline']
hulu_movies_plotline_w = ' '.join(hulu_plotline_movies_t)
stopwords = set(STOPWORDS)
wordcloud_hulu_plotline_movies = WordCloud(width = 1000, height = 500,
background_color ='white',
stopwords = stopwords,
min_font_size = 10
).generate(hulu_movies_plotline_w)
print('\nThe Wordcloud Generated from Plotlines of Hulu is : \n')
# plot the WordCloud image
plt.figure(figsize = (20, 10), facecolor = None)
plt.imshow(wordcloud_hulu_plotline_movies)
plt.axis("off")
plt.tight_layout(pad = 0)
plt.show()
The Wordcloud Generated from Plotlines of Hulu is :
# Prime Video Wordcloud
prime_video_plotline_movies_t = prime_video_plotline_movies['Plotline']
prime_video_movies_plotline_w = ' '.join(prime_video_plotline_movies_t)
stopwords = set(STOPWORDS)
wordcloud_prime_video_plotline_movies = WordCloud(width = 1000, height = 500,
background_color ='white',
stopwords = stopwords,
min_font_size = 10
).generate(prime_video_movies_plotline_w)
print('\nThe Wordcloud Generated from Plotlines of Prime Video is : \n')
# plot the WordCloud image
plt.figure(figsize = (20, 10), facecolor = None)
plt.imshow(wordcloud_prime_video_plotline_movies)
plt.axis("off")
plt.tight_layout(pad = 0)
plt.show()
The Wordcloud Generated from Plotlines of Prime Video is :
# Disney+ Wordcloud
disney_plotline_movies_t = disney_plotline_movies['Plotline']
disney_movies_plotline_w = ' '.join(disney_plotline_movies_t)
stopwords = set(STOPWORDS)
wordcloud_disney_plotline_movies = WordCloud(width = 1000, height = 500,
background_color ='white',
stopwords = stopwords,
min_font_size = 10
).generate(disney_movies_plotline_w)
print('\nThe Wordcloud Generated from Plotlines of Disney+ is : \n')
# plot the WordCloud image
plt.figure(figsize = (20, 10), facecolor = None)
plt.imshow(wordcloud_disney_plotline_movies)
plt.axis("off")
plt.tight_layout(pad = 0)
plt.show()
The Wordcloud Generated from Plotlines of Disney+ is :